<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * 员工管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array('type'=>3,'uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid);
	if(isset($_RQ['status'])){
		$params['status']=intval($_RQ['status']);
		$return['params']['status']=$_RQ['status'];
	}
	if(!empty($_RQ['ordersn'])){
		$params['ordersn like']='%'.trim($_RQ['ordersn']).'%';
		$return['params']['ordersn']=$_RQ['ordersn'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_peimilk_orderlog',$params,array($pindex,$psize),$total,$fields,'','id desc');
	foreach($list as &$item){
		$member=pdo_get('jy_peimilk_member',array('mid'=>$item['mid'],'uniacid'=>$_SESSION['uniacid']));
		$item['username']=$member['title'];
		$store=pdo_get('jy_merch_user',array('id'=>$item['merchid'],'uniacid'=>$_SESSION['uniacid']),array('merchname','logo'));
		$item['merchname']=$store['merchname'];
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'奖励列表'),
		),
		'list'=>array('data'=>'list','list'=>array(
			array('name'=>'username','title'=>'配送员','type'=>'string'),
			array('name'=>'merchname','title'=>'所属商户','type'=>'string'),
			array('name'=>'ordersn','title'=>'订单编号','type'=>'string'),
			array('name'=>'get_money','title'=>'奖励费用','type'=>'string'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'fee_status'),
		)),
		'search'=>array(
			array('type'=>'string','width'=>15,'name'=>'ordersn','title'=>'订单编号'),
			array('name'=>'status','width'=>15,'title'=>'状态','type'=>'radio','options'=>'fee_status'),
		),
	);
	$return['htmls']=$htmls;
	$return['fee_status']=$this->fee_status;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_peimilk_orderlog',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}